package wator.util;

import java.util.Hashtable;
import java.util.Vector;

public class GlobalConfiguration {
	public static final boolean debug=false;
	public static final String[] 
    debugCommands={
		"sel predator Shark",
		"sel prey Fish",
		"set Shark str Random(5)",
		"set Fish str Random(6)",
	};
	
	public static int winnerRule(int predators,int preys)
	{
		/*
		 * 0	: nobody wins
		 * 1	: predators win
		 * 2	: preys win
		 */
		if(predators==0 && preys>0)
			return 2; //preys win
		if(preys==0)
			return 1; //predators win
		else
			return 0; //nobody wins
	}
	
	public static int overallWinnerRule(int unknown,int predWins,int preyWins)
	{
		return overallWinnerVote(unknown,predWins,preyWins);
	}
	
	public static int overallWinnerMax(int unknown,int predWins,int preyWins)
	{
		int [] res={unknown,predWins,preyWins};
		int max=-1;
		int k=-1;
		for(int i=0;i<3;i++)
		{
			if(res[i]>max)
			{
				max=res[i];
				k=i;	
			}
		}
		return k;
	}
	
	public static int overallWinnerVote(int unknown,int predWins,int preyWins)
	{
		float total=unknown+predWins+preyWins;
		float predWinsP=predWins/total;
		float preyWinsP=preyWins/total;
		if(predWinsP>0.5)
			return 1;
		else if(preyWinsP>0.5)
			return 2;
		else
			return 0;
	}
}
